<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:dxl="http://www.lotus.com/dxl"
    xmlns:session="java:ro.egmar.dojocache.extensions.SessionExtension"
    exclude-result-prefixes="session xs dxl">
    
    <!-- Template for text field -->
    <xsl:template match="dxl:field[@type='text']">
        <xsl:choose>
            <xsl:when test="contains(@kind,'computed')">
                <input id="{@name}h" type="hidden" readonly="readonly"></input>
                <span id="{@name}"></span> 
            </xsl:when>
            <xsl:otherwise>
                <input type="text" name="{@name}" id="{@name}" value=""></input>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <!-- Template for number field -->
    <xsl:template match="dxl:field[@type='number']">
        <xsl:choose>
            <xsl:when test="contains(@kind,'computed')">
                <input id="{@name}h" type="hidden" readonly="readonly"></input>
                <span id="{@name}"></span> 
            </xsl:when>
            <xsl:otherwise>
        <input type="text" name="{@name}" id="{@name}" value=""></input>
            </xsl:otherwise>
            </xsl:choose>
    </xsl:template>
    
    <!-- Template for number field -->
    <xsl:template match="dxl:field[@type='password']">
        <xsl:choose>
            <xsl:when test="contains(@kind,'computed')">
                <input id="{@name}h" type="hidden" readonly="readonly"></input>
                <span id="{@name}"></span> 
            </xsl:when>
            <xsl:otherwise>
        <input type="password" name="{@name}" id="{@name}" value=""></input>
            </xsl:otherwise>
            </xsl:choose>
    </xsl:template>
    
    <!-- Template for datetime field -->
    <xsl:template match="dxl:field[@type='datetime']">
        <xsl:choose>
            <xsl:when test="contains(@kind,'computed')">
                <input id="{@name}h" type="hidden" readonly="readonly"></input>
                <span id="{@name}"></span> 
            </xsl:when>
            <xsl:otherwise>
        <input type="text" name="{@name}" id="{@name}" dojoType="DropdownDatePicker" value=""></input>
            </xsl:otherwise>
            </xsl:choose>
    </xsl:template>
    
    <!-- Template for richtext field -->
    <xsl:template match="dxl:field[@type='richtext']|dxl:field[@type='richtextlite']">
        <textarea dojoType="Editor2" name="{@name}" id="{@name}" value=""></textarea>
    </xsl:template>
    
    <!-- Template for keyword field (combobox) -->
    <xsl:template match="dxl:field[@type='keyword']">
        <xsl:choose>
            <xsl:when test="dxl:keywords/@ui='dialoglist'">
                <input dojoType="ComboBox" dataUrl=""></input>
            </xsl:when>
            <xsl:when test="dxl:keywords/@ui='checkbox'">
                    <xsl:if test="dxl:keywords/dxl:textlist">
                        <xsl:for-each select="dxl:keywords/dxl:textlist/dxl:text">
                            <input type="checkbox" id="{@name}" name="{@name}" value="{text()}"></input>
                            <label for="{@name}"></label>
                        </xsl:for-each>
                    </xsl:if>   
            </xsl:when>
            <xsl:when test="dxl:keywords/@ui='radiobutton'">
                    <xsl:if test="dxl:keywords/dxl:textlist">
                        <xsl:for-each select="dxl:keywords/dxl:textlist/dxl:text">
                            <input type="radio" id="{@name}" name="{@name}" value="{text()}"></input>
                            <label for="{@name}"><xsl:value-of select="text()"/></label>
                        </xsl:for-each>
                    </xsl:if>                   
            </xsl:when>
            <xsl:when test="dxl:keywords/@ui='combobox'">
                <select id="{@name}" name="{@name}">
                    <xsl:if test="dxl:keywords/dxl:textlist">
                        <xsl:for-each select="dxl:keywords/dxl:textlist/dxl:text">
                            <option label="{text()}" value="{text()}"></option> 
                        </xsl:for-each>
                    </xsl:if>    
                </select>
            </xsl:when>
            <xsl:when test="dxl:keywords/@ui='listbox'">
                <select id="{@name}" name="{@name}" multiple="multiple">
                    <xsl:if test="dxl:keywords/dxl:textlist">
                        <xsl:for-each select="dxl:keywords/dxl:textlist/dxl:text">
                            <option label="{text()}" value="{text()}"></option>    
                        </xsl:for-each>
                    </xsl:if>    
                </select>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    
</xsl:stylesheet>



